/**
 * Crearing Simple Exception
*/

class MyException extends Exception {               
    public MyException(String msg) {super(msg);} 
    public MyException() {} 
}

        
public class ExampleException {
    
    static void DoSomthing(int n) throws MyException{ //modification with "throws MyException" 
        if (n>0) {
            int a=100/n;   
        } else {   
            //My exception if n<0 
            throw new MyException("Input value < 0! ");
        }
    }
        
    public static void main(String[] args){
        try {   //try-block is need, because method DoSomthing() with "throws MyException"    
            DoSomthing(-1);                         
        } catch(MyException me1) { //catch My Exception only
            System.err.print(me1);   
  
        }
    }
}


/**
 *     Runtime Exception
 */
/*
class MyRunException extends RuntimeException 
{               
    public MyRunException(String msg) {super(msg);} 
}

        
public class ExampleException 
{
    static void DoSomthing(int n) //no midication for !RuntimeException! and his subclassa
    { 
        if (n>0) 
        {
            int a=100/n;   
        } else {       
            //Exception if n<0
            throw new MyRunException("Input value < 0!");
        }
    }
        
    public static void main(String[] args){        
    	DoSomthing(-1); // this work but unsafe
    }
}
*/

/**
 * Change level Exception
 */
/*
import java.io.IOException;

public class ExampleException 
{
    static void DoSomthing(int n)      //no modification
    { 
        if (n>0) 
        {
            int a=100/n;   
        } else {       
            //creation and throw the basic exception  
            IOException io = new IOException("IO exception");
            throw new RuntimeException(io); // include in RuntimeException for change level
        }
    }
        
    public static void main(String[] args){        
            try 
            {  
            	DoSomthing(-1); 
            } catch(RuntimeException e) { //catch RuntimeException exception 
            	System.err.print(e);
            }
    }
}
*/